package com.myacg.editor.common.unit.html;

public class InputElementBlock extends ElementBlock{
	public InputElementBlock(String typeName) {
		super("input");
		addAttribute("type", typeName);
		addAttribute("value", "");
	}
	public InputElementBlock(String typeName,String value) {
		super("input");
		addAttribute("type", typeName);
		addAttribute("value", value);
	}

	@Override
	public ElementBlock addElementChild(String name, String text) {
		// input标签无子节点
		return this;
	}
	 
	
	@Override
	public ElementBlock addChild(ElementBlock elementBlock) {
		// input标签无子节点
		return this;
	}
	
	@Override
	public ElementBlock appendText(String text) {
		// input标签无text
		return this;
	}
	/**
	 * 获取
	 * @return
	 */
	public String  getValue() {
		return this.attrItems.getItemValue(name);
	}
	/**
	 * 为input设置值
	 * @param value
	 */
	public void setValue(String value){
		this.attrItems.add("value", value);
	}
	
	
	@Override
	public String getStartTag() {
		return  "<"+this.name+(attrItems.print().length()>0 ? " "+attrItems.print()+" " : "")+" />";
	}
	@Override
	public String getEndTag() {
		return "";
	}
}
